package com.editso.haier.result.commodity;

import com.editso.haier.entity.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.HashSet;
import java.util.Set;

@Data
@AllArgsConstructor
public class DetailsTag {
    private String name;
    private Integer id;

    public static DetailsTag from(Tag tag) {
        return new DetailsTag(tag.getName(), tag.getId());
    }

    public static Set<DetailsTag> from(Iterable<Tag> iterable) {
        Set<DetailsTag> tags = new HashSet<>();
        for (Tag tag : iterable) tags.add(from(tag));
        return tags;
    }
}
